<!DOCTYPE HTML>
<html>
<head>
    {include file='common_header'}
    <title>订单列表</title>
</head>
<body>
<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i> 首页
    <span class="c-gray en">&gt;</span> 订单管理 <span class="c-gray en">&gt;</span>订单列表
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href='{:Url('showlist')}');" title="刷新" >
        <i class="Hui-iconfont">&#xe68f;</i>
    </a>
</nav>
<div class="page-container">
    <div class="cl pd-5 bg-1 bk-gray">
        <a href="javascript:;" onclick="upstate('{$order_up}')" >
            {if condition="$order_up eq 1"}
                <p class="btn btn-success radius">关闭抢单</p>
            {else/}
                <p class="btn btn-danger radius">开启抢单</p>
            {/if}
        </a>
        <div style="float: right">
            <span  style="margin-left:14px;" class="text-c">
                <span class="select-box inline">
                        <select id="o_type" class="select "  style="width: 180px">
                            <option value=""  >请选择订单类型</option>
                            <option value="1"  {if condition="$o_type eq 1"}selected{/if}>配送</option>
                            <option value="2" {if condition="$o_type eq 2"}selected{/if}>自提</option>
                        </select>
                </span>
                <span class="select-box inline">
                        <select id="o_status" class="select "  style="width: 180px">
                            <option value=""  >请选择订单状态</option>
                            <option value="1"  {if condition="$o_status eq 1"}selected{/if}>待支付</option>
                            <option value="2" {if condition="$o_status eq 2"}selected{/if}>待取货/自提</option>
                            <option value="3"{if condition="$o_status eq 3"}selected{/if}>配送中</option>
                            <option value="4"{if condition="$o_status eq 4"}selected{/if}>待评价</option>
                            <option value="5"{if condition="$o_status eq 5"}selected{/if}>已评价</option>
                        </select>
                </span>
                <span class="select-box inline">
                        <select id="o_paytype" class="select "  style="width: 180px">
                            <option value=""  >请选择支付方式</option>
                            <option value="1"  {if condition="$o_paytype eq 1"}selected{/if}>余额</option>
                            <option value="2" {if condition="$o_paytype eq 2"}selected{/if}>支付宝</option>
                            <option value="3"{if condition="$o_paytype eq 3"}selected{/if}>微信</option>
                        </select>
                </span>
            </span>
             <input type="text" onfocus="WdatePicker()" value="{$begin}" placeholder="支付开始时间" id="begin" class="input-text Wdate" style="width:150px;">
             --
            <input type="text" onfocus="WdatePicker()"  value="{$end}" placeholder="支付结束时间" id="end"  class="input-text Wdate" style="width:150px;">
            <input type="text" class="input-text" style="width:250px" placeholder="输入用户姓名" id="keywords" value="{$keyword}">
            <button type="button" class="btn btn-success" onclick="reload()"><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
        </div>
        <table class="table table-border table-bordered table-bg">
            <thead>
            <tr>
                <th scope="col" colspan="10"></th>
            </tr>
            <tr class="text-c">
                <th width="80">订单编号</th>
                <th width="80">用户名</th>
                <th width="80">支付金额</th>
                <th width="80">订单类型</th>
                <th width="80">订单状态</th>
                <th width="80">支付方式 </th>
                <th width="100">支付时间</th>
                <th width="100">超时状态</th>
                <th width="100">操作</th>
            </tr>
            </thead>
            <tbody>
            {volist name="list" id="v"}
            <tr class="text-c">
                <td>{$v->o_number}</td>
                <td>{$v->user_nickname}</td>
                <td>{$v->o_paymoney}</td>
                <td>
                    {if condition="$v['o_type'] eq 1"}
                        配送
                    {else/}
                        自提
                    {/if}
                </td>
                <td class="td-status">
                    {switch $v->o_status}
                        {case 1}    <span class="btn btn-success radius" >待支付</span>{/case}
                        {case 2}

                                    {if condition="$v['o_type'] eq 1"}
                                        待取货
                                    {else/}
                                        待自提
                                    {/if}

                        {/case}
                        {case 3}      配送中{/case}
                        {case 3}      待评价{/case}
                        {case 3}     已评价{/case}
                    {/switch}
               </td>
                <td class="td-status">
                    {switch $v->o_paytype}
                        {case 1}    余额{/case}
                        {case 2}     支付宝 {/case}
                        {case 3}    微信{/case}
                    {/switch}
                </td>
                <td>{$v->o_paytime|date="Y-m-d H:i:s",###}</td>
                <td>
                    {if condition="$v['o_isovertime'] eq 1"}
                        正常
                    {else/}
                    <span class="btn btn-danger radius">已超时</span>
                    {/if}
                </td>
                <td class="td-manage">
                    <a title="查看详情"  onclick="layer_show('订单详情','{:url('showdetails',array('id'=>$v['id']))}','','')"  class="btn btn-primary radius"style="text-decoration:none;" >
                        <i class="Hui-iconfont">&#xe725;</i>
                    </a>
                </td>
            </tr>
            {/volist}
            </tbody>
        </table>
        <div class="page">
            {$page}
        </div>
    </div>
    <!--_footer 作为公共模版分离出去-->
    {include file='common_footer'}
    <!--/_footer 作为公共模版分离出去-->
</div>
</body>
<script>
    function reload() {
       var obj =$('#keywords').val();
       var begintime =$('#begin').val();
       var endtime =$('#end').val();
        var o_type = $("#o_type option:selected").val();
        var o_status = $("#o_status option:selected").val();
        var o_paytype = $("#o_paytype option:selected").val();
        goUrl('?keyword=' + obj+"&begin="+begintime+"&end="+endtime+'&o_type='+o_type+'&o_status='+o_status+'&o_paytype='+o_paytype);
    }
    function upstate(order_up) {
        if(order_up==1){
            $msg="确认要关闭抢单功能？";
        }else{
            $msg="确认要开启抢单功能？";

        }
        layer.confirm($msg,function(){
            $.ajax({
                type: 'POST',
                url: "{:url('order_state')}",
                data:{order_up:order_up},
                dataType: 'json',
                success: function(data){
                    layer.msg(data.msg,{icon:1,time:1000},function () {
                        location.reload();
                    });
                },
                error:function(data) {
                    console.log(data.msg);
                }
            });
        });
    }
</script>
</html>